package exception;

import valuetypes.DBValue;

public class EntryException extends Exception {

	private static final long serialVersionUID = -7327573408076781535L;
	private static String MESSAGE_FORMAT_BAD_ENTRY = "Value %1$s is not valid for field %2$s";
	private static String MESSAGE_FORMAT_FIELD_READ_ONLY = "Cannot set Value, Field: %1$s is read-only";
	private String message;
	
	@Override
	public String getMessage() {
		return message;
	}
	
	public static EntryException badEntry(String fieldName, DBValue value) {
		EntryException ex = new EntryException();
		ex.message = String.format(MESSAGE_FORMAT_BAD_ENTRY, value.toString(), fieldName);
		return ex;
	}

	public static EntryException readOnly(String fieldName) {
		EntryException ex = new EntryException();
		ex.message = String.format(MESSAGE_FORMAT_FIELD_READ_ONLY, fieldName);
		return ex;
	}
	
	
	
	
}
